package customerEnter.Frame.JDBCDao;

import customerEnter.Frame.DaoDataTransmission.DaoFrameDMLBaseTransmission;
import customerEnter.Frame.DaoDataTransmission.DaoFramePameTransmission;
import customerEnter.Frame.DaoDataTransmission.FrameBeanSuper;
import customerEnter.Frame.JDBCDao.Interface.DaoFrameInterface;
import customerEnter.Frame.JDBCDao.Interface.DaoFrameIntermediateLayerInterface;
import customerEnter.Frame.JDBCDao.Interface.InitializationInterface;
import customerEnter.Frame.JDBCDao.Interface.ParametersResultInterface;
import customerEnter.Frame.JDBCDao.daoFrame.InitializationData;
import customerEnter.Frame.Utils.Log4j;

/**
 * 數據查詢的集合設計 易擴展和進化 使用默認權限
 * 
 * @author S-2-dy
 * @param T
 *            返回的類
 * @param TableNam
 *            要查詢表的名字
 * @param SQLDataBase
 *            查詢的數據庫名字
 */
public class DaoFrame<T, K extends FrameBeanSuper> implements DaoFrameInterface<T, K> {

	DaoFrameIntermediateLayerInterface<T, K>	daoTransmission;

	final static InitializationInterface		initialization;

	static {
		initialization = new InitializationData();
		Log4j.Log4jOutInfo("創建:" + initialization.getClass().getName());
	}

	public DaoFrame() {
		Log4j.Log4jOutInfo("初始化：" + this.getClass());
		daoTransmission = initialization.initializationDaoFrameTransmission(daoTransmission);
		initialization.initializationSqlController();
	}

	@SuppressWarnings("rawtypes")
	@Override
	public ParametersResultInterface DMLTransmission(DaoFrameDMLBaseTransmission daoFrameDMLBaseTransmission) {
		return daoTransmission.DMLTransmission(daoFrameDMLBaseTransmission,
				new DaoFramePameTransmission<T, K>(daoFrameDMLBaseTransmission.getFrameDataSqlDMLUse()))
				.getPagingParametersResult();
	}

	/**
	 * 查詢統計數據
	 */
	// public Integer QueryCount(String sql) {
	// return EasyBuyDB.getJdbcTemplate().queryForObject(sql, Integer.class);
	// }

	// /**
	// * 刪除數據
	// */
	// public Integer deleteObject(String sql) {
	// Integer in = 0;
	// try {
	// in = EasyBuyDB.getJdbcTemplate().update(sql);
	// } catch (Exception e) {
	// in = 0;
	// }
	// return in;
	// };

	/**
	 * 緩存，默認存在1分鐘
	 */
	// public void setCacheTime(int cacheTime, TimeUnit timeUnit) {
	//
	// }

	/*
	 * @Autowired RedisTemplate<String, String> redisTemplate;
	 */

	// @Autowired
	// AggregateUnionExecute aggregateUnionExecuteServer;
	//
	// @Resource(name = "jdbcTemplateService")
	// public JdbcTemplateService jdbcTemplateService;

}
